import React, { Component } from 'react'

export default function (Son) {
  // 注意: react调试工具,优先显示组件静态属性displayName的值.如果没有displayName则显示静态属性name的值
  return class Common extends Component {
    static displayName = 'with' + Son.name
    state = {
      username: '',
      password: '',
      repassword: '',
    }
    handle = (name) => (e) => {
      this.setState({
        [name]: e.target.value.trim(),
      })
    }
    render() {
      return (
        <div>
          <Son {...this.state} handle={this.handle} {...this.props}></Son>
        </div>
      )
    }
  }
}
